package cn.tedu.lucky.draw.server.controller;

import cn.tedu.lucky.draw.server.common.result.JsonResult;
import cn.tedu.lucky.draw.server.protrocol.po.ActivityRule;
import cn.tedu.lucky.draw.server.protrocol.po.Rule;
import cn.tedu.lucky.draw.server.service.IActivityRuleService;
import cn.tedu.lucky.draw.server.service.IAtivityPrizeService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@Api(tags="活动规则管理")
public class ActivityRuleController {

    @Autowired
    private IActivityRuleService activityRuleService;


    @GetMapping("/draw/activity-rule/findRule/{id}")
    public JsonResult<List<Rule>> findRuleByActivityId(@PathVariable Long id){
        List<Rule> rules=activityRuleService.findRuleByActivityId(id);
        return JsonResult.ok(rules);
    }

    @GetMapping("/draw/activity-rule/noBindRule/{id}")
    public JsonResult<List<Rule>> noBindRule(@PathVariable Long id){

        List<Rule> rules=activityRuleService.noBindRule(id);

        return JsonResult.ok(rules);
    }

    @PostMapping("/draw/activity-rule/save")
    public JsonResult save(@RequestBody List<ActivityRule> activityRules){

        activityRuleService.saveAll(activityRules);

        return JsonResult.ok();
    }

}
